package com.cf.game.stage.npc;

import com.cf.core.event.HeartbeatEvent;
import com.cf.core.player.Player;
import com.cf.compent.RandomMachine;
import com.cf.core.stage.Stage;
import com.cf.game.message.BeatResponse;
import com.cf.game.stage.RobotPlayer;
import com.cf.game.stage.event.BeatEvent;

/**
 * game-server-Student
 * 机器人玩家
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/5/7 下午 05:56
 */
public class RobotStudent extends Student {


    private RandomMachine robotRandom = new RandomMachine(40, 100, "机器人随机器");


    public RobotStudent(Stage stage, Player enemy) {
        super(stage, new RobotPlayer(), enemy);
    }


    /**
     * 处理打击事件
     *
     * @param event
     */
    @Override
    protected void handleBeat(BeatEvent event) {
        super.handleBeat(event);
        if (!event.getSelf().equals(this) && this.robotRandom.next() && EnumStudentStatue.COMMON.getStatue().equals(this.statue)) {
            this.getStage().broadcastEvent(new BeatEvent(this));
            this.getStage().broadcastEvent(new BeatEvent(this));
        }
    }

    @Override
    protected void handleHeartbeatEvent(HeartbeatEvent event) {
        super.handleHeartbeatEvent(event);
        if (this.robotRandom.next() && EnumStudentStatue.COMMON.getStatue().equals(this.statue)) {
            this.getStage().broadcastEvent(new BeatEvent(this));
            this.getStage().broadcastEvent(new BeatEvent(this));
        }
    }
}
